package com.zyb.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zyb.dao.UserDao;
import com.zyb.pojo.User;
import com.zyb.service.UserService;


@Controller
public class IndexController {
	
	@Resource
	private UserService userService;
	
	@RequestMapping("/")
	public String hello() {
		return "login";
	}
	
	@RequestMapping("/login")
	public @ResponseBody String login(String username,String password,HttpServletRequest request) {
		
		HttpSession session = request.getSession();
		User user = userService.selectUser(username, password);
		session.setAttribute("user", user);
		System.out.println(user);
		String mString = "登陆成功";
		return mString;
	}
	
	@RequestMapping("/message")
	public String message() {
		return "message";
	}
	
	

}
